import sys

from qtpy.QtCore import Qt, QUrl
from qtpy.QtWidgets import QApplication, QWidget, QVBoxLayout

from qfluentwidgets_expand.multimedia import VideoGraphicsView


class Demo(QWidget):
    def __init__(self):
        super().__init__()
        self.vertical_layout = QVBoxLayout(self)
        self.vertical_layout.setContentsMargins(0, 0, 0, 0)

        self.video_graphics_view = VideoGraphicsView(self)
        self.video_graphics_view.setSource(QUrl('https://v16m-default.akamaized.net/51c8f246903c6df9572baed8a3525746/6790c3cd/video/tos/alisg/tos-alisg-ve-0051c001-sg/oshBieUYGGzdLleMv6IzsnQoeFAIaYcAMf2V0A/?a=2011&bti=MzhALjBg&ch=0&cr=0&dr=0&net=5&cd=0%7C0%7C0%7C0&br=958&bt=479&cs=0&ds=3&ft=XE5bCqq3mbuPD12On.XJ3wU1NmxdEeF~O5&mime_type=video_mp4&qs=0&rc=NGg6ZmlpM2k4MzU4aWUzN0BpM2R2PG05cjhwdzMzODYzNEAyLV8yNV41Xi4xNDQyMS1fYSMzcGUwMmRzYXJgLS1kMC1zcw%3D%3D&vvpl=1&l=2025012203461696110B654D76F88ECB62&btag=e000a8000'))
        self.video_graphics_view.play()

        self.vertical_layout.addWidget(self.video_graphics_view)
        self.setMinimumSize(800, 600)

        self.video_graphics_view.fullScreenChanged.connect(self.on_full_screen_changed)

    def on_full_screen_changed(self, is_full_screen):
        if is_full_screen:
            self.showFullScreen()
        else:
            self.showNormal()


if __name__ == '__main__':
    QApplication.setHighDpiScaleFactorRoundingPolicy(
        Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    app = QApplication(sys.argv)
    demo = Demo()
    demo.show()
    sys.exit(app.exec_())
